// 添加收货地址
// POST
// /member/address

import { http } from '@/utils/https'
import type { AddressItem, AddressParams } from '@/types/adress'

/**
 * 添加收货地址
 */
export const postMemberAddressApi = (data: AddressParams) => {
  return http({
    method: 'POST',
    url: '/member/address',
    data,
  })
}

// 获取收货地址列表
// GET
// /member/address
/**
 * 获取收货地址列表
 */
export const getMemberAddressApi = () => {
  return http<AddressItem[]>({
    method: 'GET',
    url: '/member/address',
  })
}
// 会员中心-地址管理
// 获取收货地址详情
// GET
// /member/address/{id}
/**
 * 获取收货地址详情
 * @param id
 */
export const getMemberAddressByIdApi = (id: string) => {
  return http<AddressItem>({
    method: 'GET',
    url: `/member/address/${id}`,
  })
}

// 会员中心-地址管理
// 修改收货地址
// PUT
// /member/address/{id}
/**
 * 修改收货地址
 * @param id
 */
export const putMemberAddressByIdApi = (id: string, data: AddressParams) => {
  return http({
    method: 'PUT',
    url: `/member/address/${id}`,
    data,
  })
}

// 删除收货地址
// DELETE
// /member/address/{id}
/**
 * 删除收货地址
 * @param id
 */
export const deleteMemberAddressById = (id: string) => {
  http({
    method: 'DELETE',
    url: `/member/address/${id}`,
  })
}
